﻿using OAuth2Authorizer;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;

namespace OAuth2AuthorizerDemo.Models
{
    public class StackExchangeProvider : OAuthProvider
    {
        private static readonly string SeAppKey = "2116";
        private static readonly string SeAppSecret = "aVEjRXuhckNl6FBovdkx4w((";
        private static readonly string SeStateString = "StackExchange State String";

        public StackExchangeProvider(string name) : base(name, SeAppKey, SeAppSecret, SeStateString)
        {

        }

        public override void Initialize(IAuthorizer authorizer, string redirectUrl)
        {
            _authorizer = authorizer;
            RedirectUrl = redirectUrl;
            var parameters = new NameValueCollection();
            parameters.Add("scope", "no_expiry");
            RegisterUrl = _authorizer.GetAuthorizeUrl(AppKey, RedirectUrl, StateString, parameters);
        }
    }
}